home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / sort2.zip / ANSTR.FUN < prev    next >
Text File  |  1993-01-04  |  633b  |  21 lines

  1. function anstr(s:string):string;
  2. { returns a string stripped of non-alphanumerics (changed to ' ')}
  3. { Copyright 1988, 1989, by J. W. Rider }
  4. var i,j:integer;
  5.  
  6. { The original version just blanked out non-alphanumerics }
  7. { begin for i:=1 to length(s) do
  8.     if not (s[i] in ['0'..'9','A'..'Z','a'..'z']) then s[i]:=' ';
  9. anstr:=s; end; }
  10.  
  11. { The current version completely eliminates non-alphanumerics from
  12.   the string, including blanks and control chars }
  13.  
  14. begin j:=0;
  15. for i:=1 to length(s) do
  16.     if (s[i] in ['0'..'9','A'..'Z','a'..'z']) then begin
  17.        inc(j); s[j]:=s[i]; end;
  18. byte(s[0]):=j;
  19. anstr:=s; end;
  20.  
  21.